﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using nSL.Libs;
using nSL.Config;
using System.Security.Cryptography;

namespace nSL
{
    /// <summary>
    /// Interaction logic for pdfConv.xaml
    /// </summary>
    public partial class pdfConv : Window
    {
        public pdfConv()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            string path = Common.CURRENT_APP_PATH;
            Console.WriteLine(path);
            FileHelper.pdfFromURL(textBox1.Text.Trim(), textBox2.Text.Trim());
            string encodetxt = CalculateSHA1(textBox1.Text);
            textBlock1.Text = encodetxt;
        }

        public static string CalculateSHA1(string text)
        {
            byte[] buffer = GetBytes(text);
            SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider();
            return BitConverter.ToString(cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "");
        }

        public static byte[] GetBytes(string str)
        {
            byte[] bytes = new byte[str.Length * sizeof(char)];
            System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
            return bytes;
        }

    }
}
